package com.rzcf.blink.pay.domain.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 订单分配来源
 *
 * @author zlg
 */
@Getter
@AllArgsConstructor
public enum DistributionSourceEnum {

    /**
     * 常规订单
     */
    SYSTEM_CREATE("0", "系统自动创建"),
    /**
     * 兑换单
     */
    AGAIN_CREATE("1", "上级账号重提"),

    /**
     * 批量补发
     */
    BATCH_CREATE("2", "批量补发"),;

    /**
     * 属性
     */
    @EnumValue
    private final String key;
    private final String value;

    private static final Map<String, DistributionSourceEnum> ENUM_MAP = Arrays
            .stream(DistributionSourceEnum.values())
            .collect(Collectors.toMap(DistributionSourceEnum::getKey, type -> type));

    @JsonCreator
    public static DistributionSourceEnum getByKey(String key) {
        return ENUM_MAP.get(key);
    }

    @JsonValue
    public String getKey() {
        return key;
    }
}
